package com.lph.service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lph.dao.CocsDaoI;
import com.lph.model.Cocs;
import com.lph.model.Msg;

@Service
public class CocsService implements BaseServiceI<Cocs>{
	@Autowired
	private CocsDaoI cdi;
	public List<Cocs> find(Cocs t) {
		List<Cocs> list=cdi.find(t);
		return list;
	}

	public Cocs get(Cocs t) {
		// TODO Auto-generated method stub
		return null;
	}

	public Msg insert(Cocs t) {
		int i=cdi.insert(t);
		Msg m=new Msg("插入失败", false);
		if(i>0){
			m.setMsg("插入成功");
			m.setIs(true);
		}
		return m;
	}

	public Msg batchInsert(String objs) {
		// TODO Auto-generated method stub
		return null;
	}

	public Msg edit(Cocs t) {
		int i=cdi.edit(t);
		Msg m=new Msg("更新失败", false);
		if(i>0) m=new Msg("更新成功", true);
		return m;
	}

	public Msg remove(Integer id) {
		int i=cdi.remove(id);
		Msg m=new Msg("删除失败", false);
		if(i>0) m=new Msg("删除成功", true);
		return m;
	}

	public Msg batchRemove(String ids) {
		String rids[]=ids.split(",");
		List<String> list=new ArrayList<String>();
		list=Arrays.asList(rids);//数组转换集合
		int i=cdi.batchRemove(list);
		Msg m=new Msg("删除失败", false);
		if (i>0) {
			m.setMsg("删除成功");
			m.setIs(true);
		}
		return m;
	}

}
